/**
 * Author: Ravi Tamada
 * URL: www.androidhive.info
 * twitter: http://twitter.com/ravitamada
 * */
package com.madev.isellcrazyitems;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.madev.isellcrazyitems.handler.DatabaseHandler;
import com.madev.sales.R;

public class AdminDashboardActivity extends Activity 
{
	Button btnLogout, btnUpdate;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        /**
         * Dashboard Screen for the application 
         * */        
        // Check login status in database
        
        DatabaseHandler ldb = new DatabaseHandler(getApplicationContext());
        
        if(ldb.isUserLoggedIn())
        {

    		setContentView(R.layout.admin_dashboard);
	
    		btnLogout = (Button) findViewById(R.id.btnLogout);
        	btnLogout.setOnClickListener(new View.OnClickListener() 
        	{
    			
    			@Override
				public void onClick(View arg0) {
    				// TODO Auto-generated method stub
    				DatabaseHandler ldb = new DatabaseHandler(getApplicationContext());
    				ldb.logoutUser();
    				Intent login = new Intent(getApplicationContext(), LoginActivity.class);
    	        	login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    	        	startActivity(login);
    	        	// Closing dashboard screen
    	        	finish();
    			}
    		});
    	

        	
        }
        else
        {
        	// user is not logged in show login screen
        	Intent login = new Intent(getApplicationContext(), LoginActivity.class);
        	login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        	startActivity(login);
        	// Closing dashboard screen
        	finish();
        }
    }
}